using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using BusinessLayer;

namespace DeAn_LapTrinhCSDL.UserControl
{
    public partial class ucTinhHinhChung : DevExpress.XtraEditors.XtraUserControl
    {
        DonDH ddh;
        VatTu vt;
        NhaCC ncc;
        public ucTinhHinhChung()
        {
            InitializeComponent();
            ddh = new DonDH();
            ddh.connect.ConnectionString = Program.strConnect;
            vt = new VatTu();
            vt.connect.ConnectionString = Program.strConnect;
            ncc = new NhaCC();
            ncc.connect.ConnectionString = Program.strConnect;
        }

        private void btnXem_Click(object sender, EventArgs e)
        {
            gridView1.Columns.Clear();
            int selected = cboTinhHinh.SelectedIndex;
            switch (selected)
            {
                case 0:
                    {
                        gridControl_KetQua.DataSource = ddh.DanhSachDonDHChuaTungNhapHang();
                        break;
                    }
                case 1:
                    {
                        gridControl_KetQua.DataSource = vt.DanhSachVatTuChuaTungDatHang();
                        break;
                    }
                case 2:
                    {
                        gridControl_KetQua.DataSource = ncc.NhaCungCapCoNhieuDonDHNhat();
                        break;
                    }
                case 3:
                    {
                        gridControl_KetQua.DataSource = vt.VatTuCoSoLuongXuatNhieuNhat();
                        break;
                    }
                case 4:
                    {
                        gridControl_KetQua.DataSource = vt.TinhHinhNhapXuatVatTu();
                        break;
                    }

            }
        }

        private void btnXuatBaoCao_Click(object sender, EventArgs e)
        {
            int selected = cboTinhHinh.SelectedIndex;
            switch (selected)
            {
                case 0:
                    {
                        frmReport report = new frmReport();
                        report.reportObject = "DanhSachDonDHChuaTungNhapHang";
                        report.Show();
                        break;
                    }
                case 1:
                    {
                        frmReport report = new frmReport();
                        report.reportObject = "DanhSachVatTuChuaTungDatHang";
                        report.Show();
                        break;
                    }
                case 2:
                    {
                        frmReport report = new frmReport();
                        report.reportObject = "NhaCungCapCoNhieuDonDHNhat";
                        report.Show();
                        break;
                    }
                case 3:
                    {
                        frmReport report = new frmReport();
                        report.reportObject = "VatTuCoSoLuongXuatNhieuNhat";
                        report.Show();
                        break;
                    }
                case 4:
                    {
                        frmReport report = new frmReport();
                        report.reportObject = "TinhHinhNhapXuatVatTu";
                        report.Show();
                        break;
                    }

            }
        }
    }
}
